home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / edit / soundzapv3_0.lha / SoundZAP.h < prev   
C/C++ Source or Header  |  1992-06-05  |  4KB  |  170 lines

  1. /* header file for SoundZAP v3.0 */
  2. #define SZVER     "SoundZAP v3.0"
  3.  
  4. /* Amiga specific includes */
  5. #include <exec/types.h>
  6. #include <libraries/dos.h>
  7. #include <libraries/dosextens.h>
  8.  
  9. /* Standard includes */
  10. #include <stdio.h>
  11. #include <time.h>
  12.  
  13. /*IFF I/O includes */
  14. #include <iff/iff.h>
  15. #include <iff/8svx.h>
  16.  
  17. /* Prototypes */
  18. void GiveUsage();
  19. void ProcessOpt(struct options *, char *);
  20. void CleanUp(struct options *, int);
  21. void AnalyzeData(struct options *);
  22. void GuidoCheck(struct options *);
  23. void ConvertRaw(struct options *);
  24. void FixSize(struct options *, ULONG);
  25. void WriteIFFStuff(struct options *);
  26. void WriteAUStuff(struct options *);
  27. void PrintIOInfo(struct options *);
  28. void ConvertVOC(struct options *);
  29. void ConvertWAV(struct options *);
  30. void ConvertMAC(struct options *);
  31. void ConvertAU(struct options *);
  32. void ConvertIFF(struct options *);
  33. void maketable(signed char *, int);
  34. void maketableII(unsigned char *);
  35. void ChangeRate(struct options *);
  36. int  ulaw2linear(unsigned char);
  37. int  getscale(struct options *);
  38. UWORD GetRateFromString(struct options *, char *);
  39. ULONG ScrewIntel(ULONG);
  40. unsigned char st_linear_to_ulaw( signed char);
  41. struct ChunkInfo GetChunks(ULONG *, int, struct FileHandle *);
  42.  
  43. /* Important custom defines */
  44. #define MAX(a,b) (((a) > (b)) ? (a) : (b))
  45. #define SCREWINTEL(a) ( ((a & 0xff) << 24) + ((a & 0xff00) << 8) + ((a & 0xff0000) >> 8) + ((a & 0xff000000) >> 24) )
  46.  
  47. #define DEFAULT_SIZE 51200
  48. #define DEFAULT_RATE 11395
  49.  
  50. #define RAW     'r'
  51. #define AU      'u'
  52. #define IFF     'i'
  53. #define AIFF    'a'
  54. #define VOC     'v'
  55. #define WAV     'w'
  56. #define MAC     'm'
  57. #define UNKNOWN 'k'
  58.  
  59. #define WAVE    MakeID('W','A','V','E')
  60. #define RIFF    MakeID('R','I','F','F')
  61. #define FMT     MakeID('f','m','t',' ')
  62. #define DATA    MakeID('d','a','t','a')
  63.  
  64. #define ID_TEXT MakeID('T','E','X','T')
  65. #define ID_AIFF MakeID('A','I','F','F')
  66. #define ID_COMM MakeID('C','O','M','M')
  67. #define ID_SSND MakeID('S','S','N','D')
  68.  
  69. #define GOOD_FILE       0
  70. #define ERROR_IN_FORM   1
  71. #define WRONG_TYPE      2
  72. #define NO_MEMORY       3
  73.  
  74. /* Custom data structures */
  75. struct options
  76. {
  77.     ULONG BuffSize,
  78.           Size;
  79.     BOOL  InSign,
  80.           OutSign,
  81.           KillChunk,
  82.           FibDeltIn,
  83.           MuLawIn,
  84.           MuLawOut;
  85.     UWORD SampRate,
  86.           NewRate;
  87.     BYTE  *Data,
  88.           Amp,
  89.           Bits;
  90.     char  InType,
  91.           OutType,
  92.           inname[33],
  93.           outname[33],
  94.           FileName[50], /*To be written to NAME chunk of IFF file*/
  95.           *Auth,    /*Must be perserved by read/writers*/
  96.           *Copy;    /* ditto */
  97. };
  98.  
  99. typedef struct
  100. {
  101.     ULONG magic,
  102.           hrd_size,
  103.           data_size,
  104.           encoding,
  105.           sample_rate,
  106.           channels;
  107. } AUHeader;
  108.  
  109. typedef struct
  110. {
  111.     short numChannels;
  112.     ULONG numSampleFrames;
  113.     short sampleSize;
  114.     UBYTE sampleRate[10]; /*Should be 'extended' but I'm not sure what that is*/
  115. } CommonChunk;
  116.  
  117. typedef struct
  118. {
  119.     UWORD wFormatTag,
  120.           wChannels;
  121.  
  122.     ULONG dwSamplesPerSec,
  123.           dwAvgBytesperSec;
  124.  
  125.     UWORD wBlockAlign;
  126. } WaveFmtChunk;
  127.  
  128. struct ChunkInfo
  129. {
  130.     struct ChunkInfo *Next;
  131.     ULONG Name;
  132.     LONG  Size,
  133.           Pos;
  134. };
  135.  
  136. /* Chunks to extract from 8SVX/AIFF files */
  137. ULONG Get[] =
  138. { ID_COMM, ID_SSND, ID_VHDR,
  139.   ID_BODY, ID_NAME, ID_TEXT,
  140.   ID_ANNO, ID_AUTH, ID_Copyright };
  141.  
  142.  
  143. /* Error Messages */
  144. char *ErrorMessages[] = {
  145.  
  146. /*00*/    "How the hell did you get this message???\n",
  147. /*01*/    "No filenames specified!\n",
  148. /*02*/    "No buffer size specified!\n",
  149. /*03*/    "No sample rate specified!\n",
  150. /*04*/    "Invalid switch!\n",
  151. /*05*/    "Couldn't allocate memory!\n",
  152. /*06*/    "Input file not found!\n",
  153. /*07*/    "Probably text, not sound.\n",
  154. /*08*/    "Error opening output file!\n",
  155. /*09*/    "Unsupported storage format.\n",
  156. /*10*/    "Write error!\n",
  157. /*11*/    "Error in IFF file!\n",
  158. /*12*/    "Error in WAV file!\n",
  159. /*13*/    "New sample rate must be lower than original!!!\n",
  160. /*14*/    "Bad amplification specified!\n",
  161. /*15*/    "Stereo WAV's not supported yet!\n"
  162. };
  163.  
  164. /* Global variables (eeek!) */
  165. struct FileHandle *in=NULL, *out=NULL;
  166.  
  167. LONG BodySpot;
  168. ULONG FileLen=0;
  169. BOOL AFlag;
  170.